package com.wm.wmim.connect.ws.rpcinvoke;

import com.wm.wmim.common.dto.RpcRespDTO;
import com.wm.wmim.common.utils.RpcRespUtils;
import com.wm.wmim.connect.center.api.bo.req.OnMessageReqBO;
import com.wm.wmim.connect.center.api.rpc.ConnectOnMessageRpcService;
import com.wm.wmim.connect.sdk.onmessage.bo.resp.SendMessageCommonRespBO;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @author weiming
 * @date 2024/8/24 23:16
 * @description
 */
@Service
public class OnMessageRpcInvokeService {


    @DubboReference(version = "1.0.0", check = false)
    private ConnectOnMessageRpcService connectOnMessageRpcService;


    public SendMessageCommonRespBO onMessage(String businessScene, Map<String, Object> attributes, String message) {
        RpcRespDTO<SendMessageCommonRespBO> onMessage = connectOnMessageRpcService
                .onMessage(OnMessageReqBO.builder().businessScene(businessScene).attributes(attributes).message(message).build());
        return RpcRespUtils.getData(onMessage);
    }
}
